// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({
  env: 'zbdc-6gavbhj633c62e27'
})
const db = cloud.database();

// 云函数入口函数
exports.main = async (event, context) => {
    const wxContext = cloud.getWXContext()
    console.log(wxContext.OPENID)
    let res = await db.collection('userData')
      .where({
        openid: wxContext.OPENID
      })
      .update({
        data: {
          cet6Progress: event.cet6Progress, // 测试数据
          cet4Progress: event.cet4Progress,
          kaoyanProgress:event.kaoyanProgress,
          alterTime:db.serverDate(),
          lineData: event.lineData
        },
      }).then(res => {
          console.log(res)
      })
    return res
}